#define _CRT_SECURE_NO_WARNINGS 1
#include"MyMap.h"
#include"MySet.h"
#include"RBTree.h"
#include<string>

void fun(const cyq::map<int, int>& m)
{
	cyq::map<int, int>::const_iterator itm = m.begin();
	while (itm != m.end())
	{
		//key不能修改，value可以修改
		/*itm->first++;
		itm->second++;*/
		cout << itm->first << ":" << itm->second << endl;
		++itm;
	}
	cout << endl;
}

void test1()
{
	cyq::map<int, int> _m;
	_m.Insert(make_pair(1, 1));
	_m.Insert(make_pair(2, 2));
	_m.Insert(make_pair(3, 3));
	cyq::map<int,int>::iterator itm = _m.begin();
	while (itm != _m.end())
	{
		//key不能修改，value可以修改
		//itm->first++;
		//itm->second++;
		cout << itm->first << ":" << itm->second << endl;
		++itm;
	}
	cout << endl;

	//fun(_m);

	cyq::set<int> _s;
	_s.Insert(4);
	_s.Insert(5);
	_s.Insert(6);
	cyq::set<int>::iterator its = _s.begin();
	while (its != _s.end())
	{
		//key不能修改
		//*it++;
		cout << *its << " ";
		++its;
	}
	cout << endl;
	cout << endl;

}

void test2()
{
	cyq::map<string, string> dict;
	dict.Insert(make_pair("sort", "xxx"));
	dict["insert"];  //插入
	dict["sort"] = "排序"; //修改
	dict["insert"] = "插入"; //修改
	dict["erase"] = "删除"; //插入+修改

	cyq::map<string, string>::iterator it = dict.begin();
	while (it != dict.end())
	{
		cout << it->first << ":" << it->second << endl;
		++it;
	}
	cout << endl;


}

//统计水果的次数
void test3()
{
	string a[] = { "西瓜","哈密瓜","哈密瓜", "哈密瓜", "哈密瓜", "哈密瓜","西瓜","苹果","苹果" ,"苹果","哈密瓜" };
	cyq::map<string, int> countMap;

	for (const auto& e : a)
	{
		countMap[e]++;
	}

	for (const auto& e : countMap)
	{
		cout << e.first << ":" << e.second << endl;
	}

}

int main()
{
	test1();

	test2();

	test3();


	return 0;
}